package com.aj.http.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.aj.databases.entry.AlertMessageInfo;

public class QueryAlertMessageResponse extends BaseRespond {

	List<AlertMessageInfo> alertMessageInfoList = new ArrayList<AlertMessageInfo>();

	public QueryAlertMessageResponse(JSONObject json) {
		super(json);
		try {
			JSONObject result = common.getResult();
			if (result != null) {
				if (!result.isNull("msgList")) {
					JSONArray msgListJSONArray = result.getJSONArray("msgList");
					JSONObject tempObject = null;
					for (int i = 0; i < msgListJSONArray.length(); i++) {
						tempObject = msgListJSONArray.getJSONObject(i);
						AlertMessageInfo alertMessageInfo = new AlertMessageInfo();
						if (!tempObject.isNull("createDate")) {
							alertMessageInfo.setCreateDate(tempObject
									.getString("createDate"));
						}
						if (!tempObject.isNull("msgContent")) {
							alertMessageInfo.setMsgContent(tempObject
									.getString("msgContent"));
						}
						if (!tempObject.isNull("hadRead")) {
							alertMessageInfo.setHadRead(tempObject
									.getInt("hadRead"));
						}
						if (!tempObject.isNull("id")) {
							alertMessageInfo.setId(tempObject.getInt("id"));
						}
						if (!tempObject.isNull("msgTitle")) {
							alertMessageInfo.setMsgTitle(tempObject
									.getString("msgTitle"));
						}
						if (!tempObject.isNull("msgType")) {
							alertMessageInfo.setMsgType(tempObject
									.getInt("msgType"));
						}
						if (!tempObject.isNull("reciveUserId")) {
							alertMessageInfo.setReciveUserId(tempObject
									.getString("reciveUserId"));
						}

						if (!tempObject.isNull("relationId")) {
							alertMessageInfo.setRelationId(tempObject
									.getString("relationId"));
						}

						if (!tempObject.isNull("updateDate")) {
							alertMessageInfo.setUpdateDate(tempObject
									.getString("updateDate"));
						}
						alertMessageInfoList.add(alertMessageInfo);
					}
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public List<AlertMessageInfo> getAlertMessageInfoList() {
		return alertMessageInfoList;
	}

	public void setAlertMessageInfoList(
			List<AlertMessageInfo> alertMessageInfoList) {
		this.alertMessageInfoList = alertMessageInfoList;
	}

}
